<?php
  require_once('../db.php');
  $id = isset($_REQUEST['id']) && !empty($_REQUEST['id'])?$_REQUEST['id']:0;

if(isset($_POST['email']) && !empty($_POST['email']))
{
  $_POST = array_map('trim',$_POST);
  $_POST = array_map('strip_tags',$_POST);
  $_POST = array_map('mysql_real_escape_string',$_POST);
    pr($_POST);
    $query = "UPDATE `users` SET ";
    $tmp = '';
    foreach ($_POST as $colName => $value) {
      $tmp .= "`$colName`='$value' ,";
    }

    $query = $query.$tmp;
    $query = rtrim($query," ,");
    $query = $query." WHERE `id`='$id'";
    print_q($query);
    mysql_query($query)or die(mysql_error());
    echo "Record Updated on Id :$id";

}
$selectQuery = "SELECT * FROM `users` WHERE `id`=$id";
print_q($selectQuery);
$selectResult = mysql_query($selectQuery) or die(mysql_error());
$user = mysql_fetch_assoc($selectResult);
$isActive = $user['status']==1?'checked':'';
$isInactive = $user['status']==0?'checked':'';

pr($user);
?>
<form action="" method="post">
  <input type="hidden1" name="id" value="<?=$id?>" id="" />
  <table  border="1" cellpadding="0" cellspacing="0" width="80%" align="center">
    <thead>
      <tr>
        <th colspan="2">::Please update user::</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td align="right">User Name :</td>
        <td ><input required type="text" value="<?=$user['uname']?>" name="uname" placeholder="My Name is.."/></td>
      </tr>
      <tr>
        <td align="right">Email :</td>
        <td ><input required type="email" value="<?=$user['email']?>" name="email" placeholder="My Email is.."/></td>
      </tr>

      <tr>
        <td align="right">Status :</td>
        <td >
<label><input <?=$isInactive?> type="radio" value="0" name="status"/>Inactive</label>
<label><input <?=$isActive?> type="radio" value="1" name="status"/>Active</label></td>
      </tr>

      <tr>
        <td align="right">&nbsp;</td>
        <td ><input type="submit" value="Update It!!" /></td>
      </tr>
    </tbody>
  </table>
</form>
